package com._520it.crm.service.impl;

import com._520it.crm.domain.PaymentHandle;
import com._520it.crm.mapper.PaymentHandleMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.PaymentHandleQueryObject;
import com._520it.crm.service.IPaymentHandleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
@Service
public class PaymentHandleServiceImpl implements IPaymentHandleService {
    @Autowired
    private PaymentHandleMapper paymentHandleMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        int count = paymentHandleMapper.deleteByPrimaryKey(id);
        return count;
    }

    @Override
    public int insert(PaymentHandle record) {
        int count = paymentHandleMapper.insert(record);
        return count;
    }

    @Override
    public PaymentHandle selectByPrimaryKey(Long id) {
        return  paymentHandleMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<PaymentHandle> selectAll() {
        return  paymentHandleMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(PaymentHandle record) {
        int count = paymentHandleMapper.updateByPrimaryKey(record);
        return count;
    }

    @Override
    public PageResult queryPage(PaymentHandleQueryObject pmhqo) {
        Integer total = paymentHandleMapper.queryForCount(pmhqo);
        if(total == 0){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<PaymentHandle> rows = paymentHandleMapper.queryForRows(pmhqo);
        return new PageResult(total,rows);
    }


}
